<!DOCTYPE html>
<html dir="ltr" lang="zh-CN">
    <head>
        <meta charset="UTF-8" />
        <title></title>
        <link rel="stylesheet" type="text/css" media="all" href="http://justdoit.dev/Public/css/public.css" />
        <script>window.onerror=function(){return true;}</script>
        <script type="text/javascript" src="/Public/js/jquery.min.js"></script>
        <script type="text/javascript" src="/Public/js/uploadify/swfobject.js">
        </script><script type="text/javascript" src="/Public/js/uploadify/jquery.uploadify.min.js"></script>
    </head>
<style>
    #wrap{font-size: 12px;}
    #uploadZone{float: left;width: 180px;height: 30px;overflow: hidden;line-height: 2.2em;}
    .uploadto{float: left;width:260px; height: 20px;}
</style>
<script type="text/javascript">
    $(document).ready(function() {
        var multi="<#$multi#>";
        $('#file_upload').uploadify({
            'uploader'  : '/Public/js/uploadify/uploadify.swf',
            'script'    : '/Public/js/uploadify/uploadify.php',
            'cancelImg' : '/Public/js/uploadify/cancel.png',
            'folder'    : '/Public/upload',
            'auto'      : true,
            'multi'     : (multi=="FALSE")?false:true,
            'buttonText':'Files',
            'onComplete'  : function(event, ID, fileObj, response, data) {
                    
                if($("#toContentArea").is(":checked"))
                    if(window.parent)window.parent.insertInnerHtml("<img src='"+fileObj.filePath+"' />");
                if($("#toDatabase").is(":checked"))
                    upload2database(fileObj);
            }
        });

        function upload2database(obj){
            $.ajax({
                url:'<#url class=Attach function=saveFile ac=save unique=$unique#>',
                type:'GET',
                data:{filepath:obj.filePath,type:obj.type},
                success:function(data){
                    if(data.indexOf("saved")){}
                    else{}
                }
            });return;
        }
    });
</script>
</body>
<div id="wrap">
    <div class="ml10 mt10 uploadto">
        <input type="checkbox" name="uploadto[]" id="toContentArea" value="content" /> 传至内容区
        <input type="checkbox" name="uploadto[]" value="database" id="toDatabase" checked /> 传至媒体库
    </div>

    <div id="uploadZone">
        <input id="file_upload" name="file_upload" type="file" />
    </div>

    <br class="clear" />
</div>
</body>
</html>